function employeeService(p) {
  return `${window.RPConfig.mgt}/employee/${p}`;
  // return `/employee/${p}`
}

export const getEmployeeList = ({ responseProcess, param, initParam }) => {
  const _param = Object.assign({}, param, initParam);
  $http.post(employeeService("list/page"), _param).then(({ data }) => {
    // let { records } = data;
    // data.records = records.map(item => {
    //   if (item.deptOrgName && item.deptOrgName.length > 0) {
    //     item._disabled = true;
    //   }
    //   return item;
    // });
    return responseProcess(data);
  });
};

// 查看详情
export const getEmployeeDetail = empId => $http.post(employeeService(`detail?empId=${empId}`));
// 修改员工
export const modifyEmployee = param => $http.post(employeeService(param.id ? "update" : "add"), param);
// 删除员工
// export const deletEmployee = dels => $http.post(employeeService("delete"), dels);

// 查看挂职 - 旧未分页
// export const getJobList = empId => $http.get(employeeService(`getPositions?employeeNo=${empId}`));
// 查看挂职 - 分页 2020-03-19
export function getJobList({ responseProcess, param, initParam }) { 
  $http.post(employeeService("position/list/page"), param).then(res => {  
    // 状态为有效：禁用复选框，不可删除
    let { records } = res.data;
    records = this.$root.$options.filters["selection-disabled"](records); 
    responseProcess(res.data);
  });  
};



export const getJobDetail = id => $http.post(employeeService(`job/detail?jobId=${id}`));

export const modifyJobEmployee = param =>
  $http.post(employeeService(param.id ? "updatePositionByEmployeeJobId" : "addPosition"), param);

export const forceModifyJobEmployee = param =>
  $http.post(employeeService(param.id ? "forceUpdatePositionByEmployeeJobId" : "forceAddPosition"), param);

export const deletJobEmployee = dels => $http.post(employeeService("job/delete"), dels);
